<?
/***********************************************************/
/* Class defining the CVSTree
/* by Pablo Dall'Oglio 2001-2006.
/***********************************************************/
class CVSTree extends GtkCTree
{
    /***********************************************************/
    /* Constructor Method
    /***********************************************************/
    function CVSTree()
    {
		parent::__construct(1, 0, array(Trans::Translate('CVS')));
		parent::set_selection_mode(GTK_SELECTION_SINGLE);
		parent::set_line_style(GTK_CTREE_LINES_SOLID);
		parent::connect_simple('tree-select-row', array(&$this, 'Abrir'));
        
        $this->Botao = new GtkButton;	
    }

	/**
	 * Opens a new page in the editor section. The type of the new page depends
	 * on the element the user clicked on.
	 */
	function Abrir()
	{
        global $Pixmaps;
		$selecao = $this->selection[0];
		$Arquivo = parent::node_get_row_data($selecao);
		$NodeInfo = parent::node_get_pixtext($selecao,0);

        if ($Arquivo=='home')
        {
            parent::expand($selecao);
        }
        else
		{
			$botao = $this->Botao;
			$botao->clicked();
		}
	}
 
 	/**
	 * Opens a directory or a database element???
	 *
	 * @param	string	Name of the directory to open
	 * @param	string	Node name ???
	 * @param	string	Project name (as recorded in configuration files)
	 * @param	array	Array containing the properties of all projects known
	 */
	function AddProject($Project, $Properties)
	{
        global $Pixmaps;
		$ico = $Pixmaps['home'];
        $icologin = $Pixmaps['login'];
        $icochec  = $Pixmaps['checkout'];
        $icologout= $Pixmaps['logout'];

        $Properties['Project'] = $Project;

		if (!$NodoRaiz)
		{
            if ($Properties['server'] and $Properties['cvs_user'])
            {
                $cvs = parent::insert_node(
                    $NodoNull, null, array(':: ' . $Project), 5,
                    $ico[0], $ico[1], $ico[0], $ico[1], false, false);
    
                parent::node_set_row_data($cvs, 'home');
                $this->opened[$Diretorio] = true;
                $this->nodes[$Diretorio] = $NodoRaiz;

                $Properties['CVS'] = 'login';
                $login = parent::insert_node(
					$cvs, null, array(Trans::Translate('Login')), 5,
					$icologin[0], $icologin[1], $icologin[0], $icologin[1], false, false);
				parent::node_set_row_data($login, $Properties);

                $Properties['CVS'] = 'checkout';
                $checkout = parent::insert_node(
					$cvs, null, array(Trans::Translate('Checkout')), 5,
					$icochec[0], $icochec[1], $icochec[0], $icochec[1], false, false);
				parent::node_set_row_data($checkout, $Properties);

                $Properties['CVS'] = 'logout';
                $logout  = parent::insert_node(
					$cvs, null, array(Trans::Translate('Logout')), 5,
					$icologout[0], $icologout[1], $icologout[0], $icologout[1], false, false);
				parent::node_set_row_data($logout, $Properties);
            }
		}
	}
}
?>
